/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sp.panelcomponent;

import java.awt.CardLayout;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import sp.controller.ListingControllerTest;
import sp.form.Hal1Listing;
import sp.form.Hal2Listing;
import sp.util.CardLayoutController;

/**
 *
 * @author Istiqomah [12.7194]
 */
public class EntryFormListingTest extends javax.swing.JPanel {
    public ListingControllerTest controller;
    private CardLayoutController clc;
    /**
     * Creates new form DataEntryListingTest
     */
    public EntryFormListingTest() {
        initComponents();
//        setWarnaButton(h1);
//        setWarnaButton(h2);
        setActive(h1);
        setInactive(h2);
        setCardManager();
        h1.setBackground(new Color(45,79,123));
        h2.setBackground(new Color(45,79,123));
        controller = new ListingControllerTest(this, nextBtn, getBackBtn(), getCloseBtn(), getSaveBtn(), MainPanel);
    }
    
    public void setActive(JButton hal) {
        hal.setForeground(new Color(217, 226, 233));
    }

    public void setInactive(JButton x) {
        x.setForeground(new Color(44, 62, 80));
        
    }
    
     public void setWarnaButton(JButton hal){
        hal.setForeground(new Color(217, 226, 233));
        hal.setBackground(new Color(45,79,123));
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bgquest1 = new sp.background.Bgquest();
        backBtn = new sp.componentButton.BackminButton();
        nextBtn = new sp.componentButton.NextButton();
        closeBtn = new sp.componentButton.Closebutton();
        saveBtn = new sp.componentButton.Savebutton();
        h1 = new javax.swing.JButton();
        h2 = new javax.swing.JButton();
        closeminbutton1 = new sp.componentButton.Closeminbutton();
        minimizebutton1 = new sp.componentButton.Minimizebutton();
        errorTable2 = new sp.panelcomponent.ErrorTable();
        MainPanel = new javax.swing.JPanel();
        hal1 = new javax.swing.JScrollPane();
        hal1Listing1 = new sp.form.Hal1Listing();
        hal2 = new javax.swing.JScrollPane();
        hal2Listing1 = new sp.form.Hal2Listing();
        errField = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        errDesc = new javax.swing.JTextArea();

        backBtn.setText("");
        backBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backBtnActionPerformed(evt);
            }
        });

        nextBtn.setText("");

        closeBtn.setText("");

        saveBtn.setText("");

        h1.setBackground(new java.awt.Color(210, 100, 40));
        h1.setFont(new java.awt.Font("abeatbyKai", 0, 11)); // NOI18N
        h1.setText("Hal 1");

        h2.setFont(new java.awt.Font("abeatbyKai", 0, 11)); // NOI18N
        h2.setText("Hal 2");

        closeminbutton1.setText("");

        minimizebutton1.setText("");

        MainPanel.setLayout(new java.awt.CardLayout());

        hal1.setViewportView(hal1Listing1);

        MainPanel.add(hal1, "hal1");

        hal2.setViewportView(hal2Listing1);

        MainPanel.add(hal2, "hal2");

        errField.setFont(new java.awt.Font("abeatbyKai", 0, 18)); // NOI18N
        errField.setText("Error");

        errDesc.setColumns(20);
        errDesc.setRows(5);
        jScrollPane7.setViewportView(errDesc);

        javax.swing.GroupLayout bgquest1Layout = new javax.swing.GroupLayout(bgquest1);
        bgquest1.setLayout(bgquest1Layout);
        bgquest1Layout.setHorizontalGroup(
            bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bgquest1Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(minimizebutton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(closeminbutton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(bgquest1Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addGroup(bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(bgquest1Layout.createSequentialGroup()
                        .addComponent(errorTable2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addGroup(bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(h2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(h1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(errField)
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bgquest1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE)
                        .addComponent(MainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 954, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18))
                    .addGroup(bgquest1Layout.createSequentialGroup()
                        .addGap(49, 49, 49)
                        .addComponent(backBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(nextBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(saveBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(closeBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(40, 40, 40))))
        );
        bgquest1Layout.setVerticalGroup(
            bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(bgquest1Layout.createSequentialGroup()
                .addGroup(bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(closeminbutton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(minimizebutton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(bgquest1Layout.createSequentialGroup()
                        .addGap(206, 206, 206)
                        .addComponent(errorTable2, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(errField)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(39, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bgquest1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(MainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 575, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(75, 75, 75))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bgquest1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bgquest1Layout.createSequentialGroup()
                        .addComponent(h1)
                        .addGap(29, 29, 29)
                        .addComponent(h2)
                        .addGap(348, 348, 348))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bgquest1Layout.createSequentialGroup()
                        .addGroup(bgquest1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(nextBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(backBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(closeBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(saveBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(bgquest1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(bgquest1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void backBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backBtnActionPerformed
        if(controller.getCardName().equals("hal1")){
            setActive(getH1());
            setInactive(getH2());
        }else if (controller.getCardName().equals("hal2")){
            setActive(getH2());
            setInactive(getH1());

    }//GEN-LAST:event_backBtnActionPerformed
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel MainPanel;
    private sp.componentButton.BackminButton backBtn;
    private sp.background.Bgquest bgquest1;
    private sp.componentButton.Closebutton closeBtn;
    private sp.componentButton.Closeminbutton closeminbutton1;
    private javax.swing.JTextArea errDesc;
    private javax.swing.JLabel errField;
    private sp.panelcomponent.ErrorTable errorTable2;
    private javax.swing.JButton h1;
    private javax.swing.JButton h2;
    private javax.swing.JScrollPane hal1;
    private sp.form.Hal1Listing hal1Listing1;
    private javax.swing.JScrollPane hal2;
    private sp.form.Hal2Listing hal2Listing1;
    private javax.swing.JScrollPane jScrollPane7;
    private sp.componentButton.Minimizebutton minimizebutton1;
    private sp.componentButton.NextButton nextBtn;
    private sp.componentButton.Savebutton saveBtn;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the h1
     */
    public javax.swing.JButton getH1() {
        return h1;
    }

    /**
     * @return the h2
     */
    public javax.swing.JButton getH2() {
        return h2;
    }

    /**
     * @return the h3
     */
    

    /**
     * @return the backBtn
     */
    public sp.componentButton.BackminButton getBackBtn() {
        return backBtn;
    }

    /**
     * @return the closeBtn
     */
    public sp.componentButton.Closebutton getCloseBtn() {
        return closeBtn;
    }

    /**
     * @return the saveBtn
     */
    public sp.componentButton.Savebutton getSaveBtn() {
        return saveBtn;
    }

    /**
     * @return the closeminbutton1
     */
    public sp.componentButton.Closeminbutton getCloseminbutton1() {
        return closeminbutton1;
    }

    /**
     * @return the minimizebutton1
     */
    public sp.componentButton.Minimizebutton getMinimizebutton1() {
        return minimizebutton1;
    }

    public Hal1Listing getHal1Listing1() {
        return hal1Listing1;
    }

    public Hal2Listing getHal2Listing1() {
        return hal2Listing1;
    }

    public ErrorTable getErrorTable2() {
        return errorTable2;
    }
    
    public CardLayoutController getClc() {
        return clc;
    }

    private void setCardManager() {
        clc = new CardLayoutController();
        clc.setParentCard(MainPanel);
        clc.setCardLayout((CardLayout) MainPanel.getLayout());
    }
    
    public JTextArea getErrDesc() {
        return errDesc;
    }

    public JLabel getErrField() {
        return errField;
    }
    
    
    
}
